# -*- coding: utf-8 -*-
"""
@Time ： 2023/4/15 22:55
@Auth ： 叶东宇
@File ：ransomNote.py
"""
import collections


def ransomNet(ransom, note):
    dic_ransom = collections.Counter(i for i in ransom)
    dic_note = collections.Counter(i for i in note)
    for k,v in dic_ransom.items():
        if k in dic_note:
            if dic_ransom[k] > dic_note[k]:
                return False
        else:
            return False
    return True

def from_leetcode(ransom, note):
    if len(ransom) > len(note):
        return False
    else:
        a = set(ransom)
        for i in a:
            if ransom.count(i) > note.count(i):
                return False
        return True

if __name__ == "__main__":
    ransom = "abc"
    note = "aab"
    print(ransomNet(ransom, note))
